<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>商户全称：</label>
                                <input type="text" name="stationName"/>
                            </li>
                            <li>
                                <label>商户简称：</label>
                                <input type="text" name="stationShortName"/>
                            </li>
                            <li>
                                <label>客服电话：</label>
                                <input type="text" name="stationPhone"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="contactPerson"/>
                            </li>
                            <li>
                                <label>联系人电话：</label>
                                <input type="text" name="contactPersonMobile"/>
                            </li>
                            <li>
                                <label>邀请码：</label>
                                <input type="text" name="invitationCode"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="status">
                                    <!-- 状态（0:正常; -1：禁用; -2:删除;1-待开通） -->
                                    <option value="">所有</option>
                                    <option value="0">正常</option>
                                    <option value="-1">禁用</option>
                                    <option value="1">待开通</option>
                                    <option value="-2">删除</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="service:station:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="service:station:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="service:station:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="service:station:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('service:station:edit')}]];
        var removeFlag = [[${@permission.hasPermi('service:station:remove')}]];
        var prefix = ctx + "service/station";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商户",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'stationId',
                    title: '商户ID',
                    visible: true
                },
                {
                    field: 'stationName',
                    title: '商户信息',
                    width: 250,
                    formatter: function (value,row,index){
                        return "商户全称：" + row.stationName + "<br/>"
                            + "商户简称：" + row.stationShortName + "<br/>"
                            + "客服电话：" + ($.common.isNotEmpty(row.stationPhone) ? row.stationPhone : '-') + "<br/>"
                            + "服务时间：" + row.serviceStartTime + "~" + row.serviceEndTime;
                    }
                },
                {
                    field: 'stationAddress',
                    title: '商户地址'
                },
                {
                    field: 'longitude',
                    title: 'GPS',
                    formatter: function (value,row,index){
                        return "经度：" + row.longitude +"<br/>"
                                + "纬度：" + row.latitude;
                    }
                },
                {
                    field: 'stationIntroduce',
                    title: '商户介绍'
                },
                {
                    field: 'stationImage',
                    title: '图片',
                    formatter: function(value, row, index) {
                        var firstImg = '';
                        if ($.common.isNotEmpty(value)) {
                            firstImg = value.indexOf(",") > 0 ? value.split(',')[0] : value;
                        }
                        return $.table.imageView(ctx + firstImg,'450');
                    }
                },
                /*{
                    field: 'areaId',
                    title: '商户所属地区编号'
                },*/
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        // 状态（0:正常; -1：禁用; -2:删除;1-待开通）
                        if(value == 0){
                            return "<span class='badge badge-primary'>正常</span>";
                        }else if(value == -1){
                            return "<span class='badge badge-danger'>禁用</span>";
                        }else if(value == -2){
                            return "<span class='badge badge-inverse'>删除</span>";
                        }else if(value == 1){
                            return "<span class='badge badge-warning'>待开通</span>";
                        }
                        return utils.Rmb.rmbToYuan(value);
                    }
                },
                {
                    field: 'contactPerson',
                    title: '联系人'
                },
                {
                    field: 'contactPersonMobile',
                    title: '联系人电话'
                },
                {
                    field: 'stationTag',
                    title: '商户标签'
                },
                {
                    field: 'invitationCode',
                    title: '邀请码'
                },
                {
                    field: 'tradeNum',
                    title: '累计成功交易',
                    formatter: function(value, row, index) {
                        return "交易笔数：" + row.tradeNum + "<br/>" +
                               "交易金额(元)：" + utils.Rmb.rmbToYuan(row.tradeAmount);
                    }
                },
                {
                    field: 'createTime',
                    title: '操作信息',
                    width: 250,
                    formatter: function(value, row, index) {
                        return "创建时间：" + row.createTime + "<br/>" +
                            "创建人：" + ($.common.isNotEmpty(row.createBy) ? row.createBy : '-') + "<br/>" +
                            "修改时间：" + ($.common.isNotEmpty(row.modifyTime) ? row.modifyTime : '-') + "<br/>" +
                            "修改人：" + ($.common.isNotEmpty(row.modifyBy) ? row.modifyBy : '-');
                    }
                },
                /*{
                    field: 'stationArea',
                    title: '商户所属地区'
                },*/
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.stationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.stationId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>